const express = require('express');
const app = express();
const mysql = require('mysql');
app.use(express.json());

app.get("/api/articleList",(req,res)=>{
    const conn=mysql.createConnection({
        host:'localhost',
        user:'root',
        password:'123456',
        database:'users'
    })
    conn.connect((err)=>{
        if(err) {
            console.log('数据库连接失败',err)
        }else{
            console.log('数据库连接成功！')
        }
        let  sql='select * from users'
        conn.query(sql,(err,result)=>{
            if(err) {
                console.log('查询失败',err)
            }else{
                console.log('查询成功！')
                res.send(result)
            }
            conn.end()
        })
       
    })

})

app.listen(3001,()=>{
    console.log("监听在3001端口")
})